package javacommon.base;

import java.io.Serializable;
import java.sql.SQLException;
import java.util.List;

import javacommon.web.page.Page;
import javacommon.web.page.PageRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * @author 
 */
public abstract class BaseService <E>{
	
	protected Logger log = LoggerFactory.getLogger(getClass());

	protected abstract EntityDao<E> getEntityDao();

    public E getById(Serializable id) throws SQLException{
		return getEntityDao().getById(id);
	}
	
	public List<E> findAll() throws SQLException{
		return getEntityDao().findAll();
	}
	
	/** 插入数据 
	 * @throws SQLException */
	public void save(E entity) throws SQLException{
		getEntityDao().save(entity);
	}
	
	public void removeById(Serializable id) throws SQLException{
		getEntityDao().deleteById(id);
	}
	public void removeByIds(String[] ids) throws SQLException {
		getEntityDao().deleteByIds(ids);
	}
	public void update(E entity) throws SQLException{
		getEntityDao().update(entity);
	}

	public  Page<E> findPage(PageRequest<E> query) throws SQLException{
		return getEntityDao().findPage(query);
	}
}
